<?php
/**
 * Created by PhpStorm.
 * User: 异步加载
 * Date: 2017/12/23
 * Time: 10:35
 */

namespace app\api\model;


class User extends BaseModel
{

    /**
     * @return \think\model\relation\HasOne
     * 关联user user_address  没有外键一方定义一对一关系用hasOne
     */
    public function address(){
        return $this->hasOne('UserAddress','user_id','id');
    }

    /**
     * @param $openid
     * @return array|false|\PDOStatement|string|\think\Model
     * 查找openid
     */
    public static function getByopenID($openid){
        $user = self::where('openid','=',$openid)->find();
        return $user;
    }
}